package com.hulk.dryad.manage.framework.websocket.client.config;


import com.hulk.dryad.manage.framework.websocket.client.core.WsClient;
import com.hulk.dryad.manage.framework.websocket.client.support.SingleWsClientImpl;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.SimpMessagingTemplate;

/**
 * Single websocket 客户端配置
 *
 * @author
 */
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(WebSocketClientConfiguration.class)
@AutoConfigureAfter(WebSocketClientConfiguration.class)
@ConditionalOnProperty(
	name = "enabled",
	prefix = WebSocketClientClusterProperties.PREFIX,
	havingValue = "false",
	matchIfMissing = true
)
public class SingleWsClientConfiguration {

	@Bean
	@ConditionalOnBean(SimpMessagingTemplate.class)
	public WsClient wsClient(SimpMessagingTemplate messagingTemplate) {
		return new SingleWsClientImpl(messagingTemplate);
	}

}
